'- sprites
'- background

asm
  ld sp,$EFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim ee0 as uinteger at $E014
dim ee1 as uinteger at $E016
dim ee2 as uinteger at $E018
dim ee3 as uinteger at $E01A
dim ej0 as uinteger at $E01C
dim ej1 as uinteger at $E01E
dim ej2 as uinteger at $E020
dim ex0 as uinteger at $E022
dim ey0 as uinteger at $E024


seed=0

'-----

sub vulgusputchar(tx as uinteger,ty as uinteger,tchr as ubyte,tattr as ubyte,tl as uinteger):
  poke $D000+(((  (tx band 31)  *32)+  (ty band 31)  )bxor 31)+($800*(tl band 1)),tchr
  poke $D400+(((  (tx band 31)  *32)+  (ty band 31)  )bxor 31)+($800*(tl band 1)),tattr
  end sub

sub vulgusputsprite(tlayer as ubyte,tx as ubyte,ty as ubyte,tid as ubyte,tclut as ubyte):
  '- probably very wrong addresses - it is actually between $CC00 and $CFFF
  poke $CC00+((tlayer band 255)*4),tid          '- shape sprite 0
  poke $CC01+((tlayer band 255)*4),tclut        '- clut? sprite 0
  poke $CC02+((tlayer band 255)*4),tx  bxor $ff '- x sprite 0
  poke $CC03+((tlayer band 255)*4),ty bxor $ff  '- y sprite 0
  end sub

'-----

for eee=$CC00 to $CFFF '- sprites 'for eee=$CC00 to $CC7F '- sprites
  seed=smsrnd(seed)  
  poke eee,seed
  next

for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    vulgusputchar(ee1,ee0,seed band 3,ee2 band %00001111,0)
    next:next

for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    vulgusputchar(ee1,ee0,128+seed mod 45,(ee2 band %00001111) bor %00000000,0)
    next:next



for ee0=0 to 15
  for ee1=0 to 15
    vulgusputchar(ee1+13,ee0+15,(ee0*16)+ee1,4,0)
    next:next



eee=0:ex0=8:ey0=12
do

  vulgusputchar(4,1,48+((int(eee/10000)) mod 10),4,0)
  vulgusputchar(5,1,48+((int(eee/1000)) mod 10),4,0)
  vulgusputchar(6,1,48+((int(eee/100)) mod 10),4,0)
  vulgusputchar(7,1,48+((int(eee/10)) mod 10),4,0)
  vulgusputchar(8,1,48+(eee mod 10),4,0)

  ej0=peek($C000) bxor 255
  vulgusputchar(8,3,48+(ej0 mod 10),4,0)
  vulgusputchar(7,3,48+((int(ej0/10)) mod 10),4,0)
  vulgusputchar(6,3,48+((int(ej0/100)) mod 10),4,0)

  ej0=peek($C001) bxor 255
  vulgusputchar(8,4,48+(ej0 mod 10),4,0)
  vulgusputchar(7,4,48+((int(ej0/10)) mod 10),4,0)
  vulgusputchar(6,4,48+((int(ej0/100)) mod 10),4,0)

  ex0=ex0+((ej0 band 1)/1)-((ej0 band 2)/2)
  ey0=ey0+((ej0 band 4)/4)-((ej0 band 8)/8)

  ej0=peek($C002) bxor 255
  vulgusputchar(8,5,48+(ej0 mod 10),4,0)
  vulgusputchar(7,5,48+((int(ej0/10)) mod 10),4,0)
  vulgusputchar(6,5,48+((int(ej0/100)) mod 10),4,0)

  ej0=peek($C003) bxor 255
  vulgusputchar(8,6,48+(ej0 mod 10),4,0)
  vulgusputchar(7,6,48+((int(ej0/10)) mod 10),4,0)
  vulgusputchar(6,6,48+((int(ej0/100)) mod 10),4,0)

  ej0=peek($C004) bxor 255
  vulgusputchar(8,7,48+(ej0 mod 10),4,0)
  vulgusputchar(7,7,48+((int(ej0/10)) mod 10),4,0)
  vulgusputchar(6,7,48+((int(ej0/100)) mod 10),4,0)




  vulgusputchar(ex0 band 31,ey0 band 31,32+(eee band 63),4,0)
  eee=eee+1
  smsdelay(1000)
  loop


do:loop

'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------


